package com.itgaohe.controller;

import com.itgaohe.common.R;
import com.itgaohe.pojo.Order;
import com.itgaohe.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;


@Controller
@RequestMapping("/Order")
public class OrderController {
    @Autowired
    private OrderService orderService;
//    增
    @PostMapping
    public R add(Order order){
        boolean save = orderService.save(order);
        return save?R.success("success"): R.error("error");
    }
//    删
    @DeleteMapping
    public R delete(@PathVariable Integer id){
        boolean b = orderService.removeById(id);
        return b?R.success("success"): R.error("error");
    }
//    改
    @PutMapping
    public R update(@RequestBody Order order){
        boolean b = orderService.updateById(order);
        return b?R.success("success"): R.error("error");
    }
}